Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] include/exclude filters (#1) #2

Merged
merged 14 commits into from
Jul 27, 2021
Merged

[Feature] include/exclude filters (#1) #2

merged 14 commits into from
Jul 27, 2021

Conversation

rnsc
Copy link

@rnsc rnsc commented Jun 28, 2021

Hello @Ana06 ,

Here's my attempt at the include/exclude filtering following issue #1.
I've picked up the suggestion regarding the use of regex from @micalevisk.

Disclaimer, I'm no programmer, so I hope I haven't made any terrible mistakes.

* First commit with include/exclude filters

* Enable manual workflow runs

* Updated index.js

* add an action run with filters

* required include

* negative lookup

* updated index.js

* updated package.json

* new regex test

* updated workflow

* rollback packages update

* change the invert match logic

* fix regex

* testing dummy files

* better assignment

* remove dummy test files

* original packages.json

* fix yarn issue
Copy link

@micalevisk micalevisk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well done!

@rnsc
Copy link
Author

rnsc commented Jun 30, 2021

@micalevisk @Ana06 do you think we should already merge this as is and review the suggestion on the issue #1 first or rework this completely?

@micalevisk
Copy link

micalevisk commented Jun 30, 2021

@micalevisk @Ana06 do you think we should already merge this as is and review the suggestion on the issue #1 first or rework this completely?

I like that suggestion because it seems like more idiomatic to GH Actions

with:
  paths:
    - '*.yml'
    - '!blah/test/**'

To implement this, I'd say is better to open a new PR and close this one.

Copy link
Owner

@Ana06 Ana06 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @rnsc! Thank you so much for sending a PR ❤️ and sorry for the late review, busy week! 😅
Some documentation about this great new features on the README would be nice 😉

Thanks @micalevisk for reviewing the PR and for sharing your opinion! 😄

I really do not have an strong opinion about what option we should take (GH Actions like vs include/exclude). As already two persons mentioned they prefer the GH Actions like syntax I tend to think we should use that one. @rnsc do you want to work on that or do you prefer we merge this (maybe after addressing the minor changes and adding documentation if you have time) and then someone else sends a PR for the GH Actions like implementation?

.github/workflows/test.yml Outdated Show resolved Hide resolved

- name: Print steps context output
- name: Print files
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] I think the name was accurate, but it is not very important. Does someone else has an opinion about this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to have a different name since I had duplicated the step with the exclude filter.

dist/index.js Outdated Show resolved Hide resolved
@rnsc
Copy link
Author

rnsc commented Jun 30, 2021

Great work @rnsc! Thank you so much for sending a PR ❤️ and sorry for the late review, busy week! 😅
Some documentation about this great new features on the README would be nice 😉

Thanks @micalevisk for reviewing the PR and for sharing your opinion! 😄

I really do not have an strong opinion about what option we should take (GH Actions like vs include/exclude). As already two persons mentioned they prefer the GH Actions like syntax I tend to think we should use that one. @rnsc do you want to work on that or do you prefer we merge this (maybe after addressing the minor changes and adding documentation if you have time) and then someone else sends a PR for the GH Actions like implementation?

Hey @Ana06 Thank you for taking the time to review this, don't feel pressured to do so if you have other stuff on your hands though, I was merely mentioning you for visibility regarding the feedback I had received on the issue for the feature request itself!

Adding @agraul @micalevisk too for the following inquiry:

I'll check if I can do something about accepting a list of containing both include and exclude like suggested in this example: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-using-positive-and-negative-patterns-1

The paths definition for files is not a regex but a glob pattern though.
Do you think the use of a library like this one glob is ok?

@micalevisk
Copy link

Do you think the use of a library like this one glob is ok?

I think it is since it follows the filter pattern cheat sheet (you could add this cheat sheet to the README)

@agraul
Copy link

agraul commented Jul 1, 2021

The paths definition for files is not a regex but a glob pattern though.

Isn't that already the case? Looking at the README and the current code, the default filter is *, which is a quantifier and doesn't match anything by itself. I don't understand how it currently works, JS is not a language I know well. I would expect .* is needed to match everything.

Do you think the use of a library like this one glob is ok?

I'm no expert, from a first glance it looks like it should work.

@rnsc
Copy link
Author

rnsc commented Jul 1, 2021

Hello @Ana06 @micalevisk @agraul ,

I believe I have the correct logic in place to support glob filtering.
I've updated the README with the example.
Should I also mention the library used in the README? https://github.com/isaacs/minimatch
So that people understand how the glob pattern matching is done?

Thank you for your time and feedback on this.
Again, I'm no developer, so I know my code is probably not the best!

@@ -1,16 +1,18 @@
# get-changed-files
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a bit of linting on the README too, I hope that's ok

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's awesome, thanks!

README.md Outdated Show resolved Hide resolved
README.md Outdated
@@ -22,16 +24,23 @@ See [action.yml](action.yml)
# Default: 'space-delimited'
format: ''
# Filter files using a regex
filter: '*'
glob-filter: '*'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, the verison of the action should be changed too right?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should. yarn version --no-git-tag-version --major

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, @micalevisk, @Ana06, should we also change the repository URLs in the package.json? Or are we planning on trying to merge in the original repo in the future?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did the yarn command thingie, I'll let you all check :)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we call it grob-filter or just filter? I like filter, as we don't have any other filer I think the name doesn't need to be more specific as long as we document it properly. But I don't have a strong opinion... 🤔 🤔 Any other opinion?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rnsc

should we also change the repository URLs in the package.json? Or are we planning on trying to merge in the original repo in the future?

I think we can change the urls. I was hopping upstream integrates these changes when I originally forked it, but it doesn't look like it will happen.

@@ -39,7 +39,7 @@
"all": "yarn clean && yarn build && yarn format && yarn lint && yarn package && yarn test"
},
"dependencies": {
"@actions/core": "^1.2.2",
"@actions/core": "^1.4.0",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I bumped it to a more recent version to have getMultilineInput support.

src/main.ts Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@rnsc rnsc requested a review from Ana06 July 6, 2021 10:49
format: ''
# Filter files using a regex
glob-filter: |
*.yml
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@agraul not sure if you've seen this, but as GitHub actions core doesn't support a standard YAML as input, we have to declare the list a multi line string.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the ping, I missed that. It's a bit unfortunate, I didn't know that lists can't be passed, but as long as the structure is kept I think this is still nice!

@rnsc
Copy link
Author

rnsc commented Jul 12, 2021

Hello @Ana06
Do you think you'll have time this week ro review this PR again?

Thanks!

Copy link
Owner

@Ana06 Ana06 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! Just some minor comments. Once those are addressed/discussed, let's merge this and I can release version 2.0 🎉

@@ -1,16 +1,18 @@
# get-changed-files
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's awesome, thanks!

README.md Outdated
@@ -22,16 +24,23 @@ See [action.yml](action.yml)
# Default: 'space-delimited'
format: ''
# Filter files using a regex
filter: '*'
glob-filter: '*'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we call it grob-filter or just filter? I like filter, as we don't have any other filer I think the name doesn't need to be more specific as long as we document it properly. But I don't have a strong opinion... 🤔 🤔 Any other opinion?

README.md Show resolved Hide resolved
src/main.ts Outdated Show resolved Hide resolved

## Get all changed files as space-delimited
### Get all changed files as space-delimited
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this was already like this before, but I think it would be clearer to have this Get all changed files as space-delimited without the filter option and make another section to only get *.php and give there some more details about how the filter option works (that a list of regular expression is expected, GitHub like syntax is used, etc.). Ideally users should be able to understand how it works only with the README without checking the code. I am not completely sure this is the case now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added one example

README.md Outdated
@@ -22,16 +24,23 @@ See [action.yml](action.yml)
# Default: 'space-delimited'
format: ''
# Filter files using a regex
filter: '*'
glob-filter: '*'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rnsc

should we also change the repository URLs in the package.json? Or are we planning on trying to merge in the original repo in the future?

I think we can change the urls. I was hopping upstream integrates these changes when I originally forked it, but it doesn't look like it will happen.

src/main.ts Outdated Show resolved Hide resolved
@rnsc rnsc force-pushed the main branch 2 times, most recently from b05c075 to 068f1f4 Compare July 13, 2021 17:05
@rnsc
Copy link
Author

rnsc commented Jul 22, 2021

Hello @Ana06 , I think I have made all the changes required, what would be the next steps? Not sure if can help still!

Copy link
Owner

@Ana06 Ana06 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job @rnsc and sorry for the late response. I think it is ready to merge 🎉

@Ana06 Ana06 merged commit f0220ec into Ana06:main Jul 27, 2021
Ana06 pushed a commit that referenced this pull request Jul 27, 2021
[Feature] include/exclude filters (#1)
Ana06 added a commit that referenced this pull request Jul 27, 2021
There as a discussion on the name to use in #2 and we forgot to change
these.
@@ -85,12 +85,37 @@ jobs:
- id: files
name: Run the action
uses: ./
with:
glob-filter: '*'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had skipped that one 🙈 I have fix it on main 😉

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no! Sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants